package com.loe.ui.api

import android.view.View
import android.view.ViewGroup
import com.loe.ui.page.UiPage
import com.quickjs.JSObject

/**
 * IUiViewGroup节点接口
 *
 * @author 章路顺
 * @since 2022/9/7-17:38
 */
interface IUiViewGroup: IUiView
{
    var uiPage: UiPage?

    /** 获取UiView */
    fun <T : View> findView(idName: String): T = (this as ViewGroup).findViewById(uiPage?.idMap?.get(idName) ?: 1)

    /** 获取js对象 */
    fun findObject(idName: String): JSObject = (findView(idName) as IUiView).jsObject

    /** 添加UI模板 */
    fun addChild(ui: JSObject) { uiPage?.createUI(ui, this as ViewGroup) }

//    /** 获取UiTextView */
//    fun findUiTextView(idName: String): UiTextView = findView(idName)
//
//    /** 获取UiImageView */
//    fun findUiImageView(idName: String): UiImageView = findView(idName)
//
//    /** 获取UiListView */
//    fun findUiListView(idName: String): UiListView = findView(idName)
//
//    /** 获取Ui布局 */
//    fun findUiGroup(idName: String): IUiViewGroup = findView(idName)
//
//    /** 获取UiView */
//    fun findUiView(idName: String): IUiView = findView(idName)
}